package Day_arrys;

/**
 * description: Test02 <br>
 * date: 2022/1/31 4:50 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */
public class Test02 {
    public static void main(String[] args) {
        //静态初始化
        int[] a = {2, 4, 65};
        User[] b = {new User(1001, "zs"),
                new User(1002, "ls"),
                new User(1002, "ww")
        };
        //默认初始化
        //默认给数组的元素进行赋值，赋值的规则和成员变量默认赋值规则一致
        int[] c = new int[3];
        //动态初始化
        //动态初始化数组，先分配空间
        int[] a1 = new int[2];
        //给数组元素赋值
        a1[0] = 1;
        a1[1] = 2;

        for (int m : a) {
            //for-each循环；用于读取数组元素的值，不能修改元素1的值
            System.out.println(m);
        }
        System.out.println("--------------");


        String[] ss = {"aa", "bb", "ccc", "ddd"};
        for (String temp : ss) {
            System.out.println(temp);
        }
    }
}
